package edu.pku.sei.transformation.editor.model.deploy;

import edu.pku.sei.gefcommon.descriptor.annotation.EnumerationProperty;
import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.transformation.editor.model.ModelPackage;
import edu.pku.sei.transformation.editor.model.Transformation;
import edu.pku.sei.transformation.editor.model.TypedModel;

public class ActualParameter extends MetaModelElement {
	private TypedModel formalParameter = null;
	private String file = "";
	
	
	public Transformation getTransforamtion() {
		try {
			return ((Deployment)getContainer()).getCode().getSpecification();
		} catch (NullPointerException e) {
			return null;
		}
	}
	
	@MethodProperty(id = ModelPackage.PIN_FORMAL_PARAMETER, catalog = "parameter", name = "Formal Parameter", setter = "setFormalParameter")
	@EnumerationProperty(function = "getFormalParameters")
	public TypedModel getFormalParameter() {
		return formalParameter;
	}

	public void setFormalParameter(TypedModel formalParameter) {
		if (this.formalParameter != formalParameter) {
			TypedModel oldValue = this.formalParameter;
			this.formalParameter = formalParameter;
			firePropertyChange(ModelPackage.PIN_FORMAL_PARAMETER, oldValue,
					formalParameter);
			this.container.firePropertyChange("temp", null, null);
		}
	}

	public Object[] getFormalParameters() {
		Transformation t = getTransforamtion();
		if (t == null)
			return new Object[0];
		else {
			return t.getTypedModel().toArray();
		}
	}

	@MethodProperty(id="file", catalog="parameter", name = "file", setter = "setFile")
	public String getFile() {
		return file;
	}

	public void setFile(String file) {
		this.file = file;
	}
	
	
}
